package com.wu.client.controller;

import com.wu.client.service.*;
import com.wu.client.vo.req.FavoritesReq;
import com.wu.client.vo.res.PageResp;
import com.wu.client.vo.res.album.AlbumBaseResp;
import com.wu.client.vo.res.album.AlbumResp;
import com.wu.client.vo.res.mv.MvBaseResp;
import com.wu.client.vo.res.playlist.PlaylistBaseResp;
import com.wu.client.vo.res.song.SongResp;
import com.wu.common.convertion.result.Result;
import com.wu.common.convertion.result.Results;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author Cousin
 * @date 2025/3/16
 * @Description
 */
@RestController
@RequestMapping("/user/favorites")
@RequiredArgsConstructor
public class UserFavoritesController {

    private final UserLikesService userLikesService;

    private final SongService songService;

    private final AlbumService albumService;

    private final PlaylistService playlistService;

    private final MvService mvService;
    @GetMapping("/songs")
    public Result<PageResp<SongResp>> getUserFavoritesSongs(@RequestParam Long userId, @RequestParam(defaultValue = "1") Integer page,
                                                            @RequestParam(defaultValue = "10") Integer limit) {
        return Results.success(songService.getUserFavoritesSongs(userId, page, limit));
    }
    //http://localhost:8888/api/user/favorites/albums?userId=1&limit=50
    @GetMapping("/albums")
    public Result<PageResp<AlbumResp>> getUserFavoritesAlbums(@RequestParam Long userId, @RequestParam(defaultValue = "1") Integer page,
                                                              @RequestParam(defaultValue = "10") Integer limit) {

        return Results.success(albumService.getUserFavoritesAlbums(userId, page, limit));
    }
    //http://localhost:8888/api/user/favorites/playlists?userId=1&limit=50
    @GetMapping("/playlists")
    public Result<PageResp<PlaylistBaseResp>> getUserFavoritesPlaylists(@RequestParam Long userId, @RequestParam(defaultValue = "1") Integer page,
                                                                    @RequestParam(defaultValue = "10") Integer limit) {
        return Results.success(playlistService.getUserFavoritesPlaylists(userId, page, limit));
    }
    //http://localhost:8888/api/user/favorites/mvs?userId=1&limit=50
    @GetMapping("/mvs")
    public Result<PageResp<MvBaseResp>> getUserFavoritesMvs(@RequestParam Long userId, @RequestParam(defaultValue = "1") Integer page,
                                                            @RequestParam(defaultValue = "10") Integer limit) {

        return Results.success(mvService.getUserFavoritesMvs(userId, page, limit));
    }

    @PostMapping
    public Result<Void> likeAndUnlike(@RequestBody FavoritesReq favoritesReq){
        userLikesService.likesAndUnlike(favoritesReq);
        return Results.success();
    }
}
